package cn.stronglink.assetmanage.business.inventory.presenter;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.Toast;

import java.util.List;
import java.util.Map;

import cn.stronglink.assetmanage.MainActivity;
import cn.stronglink.assetmanage.MyApplication;
import cn.stronglink.assetmanage.R;
import cn.stronglink.assetmanage.business.inventory.model.InventoryUncountModel;
import cn.stronglink.assetmanage.business.inventory.view.uncount.InventoryUncountView;
import cn.stronglink.assetmanage.business.task.view.TaskFragment;
import cn.stronglink.assetmanage.entity.Inventory;
import cn.stronglink.assetmanage.entity.InventoryDetail;
import cn.stronglink.assetmanage.index.entity.PromissionEntity;
import cn.stronglink.assetmanage.utils.Constants;

import static cn.stronglink.assetmanage.R.id.tvTitle;

/**
 * Created by chencongcong on 2018/6/15.
 */

public class InventoryUncountPresenter {
    private InventoryUncountModel inventoryUncountModel;
    private InventoryUncountView inventoryUncountView;
    //盘点表单列表
    private List<Inventory> inventoryList;
    //选择的表单
    private Inventory inventory;

    public InventoryUncountPresenter(InventoryUncountModel inventoryUncountModel,
                                     InventoryUncountView inventoryUncountView) {
        this.inventoryUncountModel = inventoryUncountModel;
        this.inventoryUncountView = inventoryUncountView;
    }

    /**
     * 初始化未盘点表单列表
     */
    public void initInventoryListView() {
        inventoryList = inventoryUncountModel.getDataByOrderNoDistince();
        inventoryUncountView.showListView();
        inventoryUncountView.setListData(inventoryList);
    }

    /**
     * 根据点击位置显示资产列表
     *
     * @param position
     */
    public void showOrderByPosition(int position) {
        // 显示盘点详情页面
        MainActivity activity = (MainActivity) this.inventoryUncountView.getFragment().getActivity();
        PromissionEntity pe = new PromissionEntity();
        pe.setPosition(MainActivity.FRAGMENT_INVENTORY_DETAIL_ID);

        // 设置打开盘点详情后传递的参数
        inventory = inventoryList.get(position);
        Bundle bundle=new Bundle();
        bundle.putSerializable(Constants.INVENTORY_DETAIL_NO, inventory.getId_());
        pe.setBundle(bundle);
        activity.onEventRegister(pe);
    }

}
